import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenTwoRouter } from '../Common/options'

export const SecurityWorkRecord = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [<AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'SecurityWorkRecord' },
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization, title: '项目' },
            {
                dataIndex: 'department',
                title: '部位',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'workDate',
                title: '日期',
                valueType: 'Date',
                showTime: true,
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'siteResponsiblePerson',
                title: '现场负责人',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'participantCount',
                title: '参与人数',
                valueType: 'inputNumber',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'protectiveEquipmentWorn',
                title: '防护用品佩戴',
                valueType: 'inputNumber',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'workEnvironmentDescription',
                title: '作业环境描述',
                valueType: 'inputNumber',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'morningEducationVideo',
                title: '早班教育内容视频',
                valueType: 'inputNumber',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'earlyChildhoodEducation',
                title: '早班教育参与情况视频',
                valueType: 'inputNumber',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'otherDetails',
                title: '其他',
                valueType: 'inputNumber',
                ellipsis: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'workContent',
                title: '工作内容',
                valueType: 'textarea',
                ellipsis: true,
                width: 200,
                hideInSearch: true,
            },

            commonTableList.updateUserName,
            commonTableList.updateTime,
            commonTableList.BeginSecurityDate,
            commonTableList.EndSecurityDate,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <OpenTwoRouter
                            key="Annex"
                            title="附件管理"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'AttachmentDetails',
                                actionRef,
                                Permission,
                                oneData: record,
                                header: data.columns,
                                tableNameList: {
                                    防护用品佩戴: '防护用品佩戴',
                                    作业环境: '作业环境',
                                    早班教育内容视频: '早班教育内容视频',
                                    早班教育参与情况视频: '早班教育参与情况视频',
                                    其他: '其他',
                                },
                            }}
                        />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
